<?php /* Smarty version Smarty-3.1.13, created on 2014-10-27 22:55:48
         compiled from "D:\workspace\php\cms\templates\admin\users\adminuser.tpl" */ ?>
<?php /*%%SmartyHeaderCode:19067544e5cf4874785-03615434%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_valid = $_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    '6d0135488cdf76cd549b257149eacf703cdc1021' => 
    array (
      0 => 'D:\\workspace\\php\\cms\\templates\\admin\\users\\adminuser.tpl',
      1 => 1414419523,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '19067544e5cf4874785-03615434',
  'function' => 
  array (
  ),
  'has_nocache_code' => false,
  'version' => 'Smarty-3.1.13',
  'unifunc' => 'content_544e5cf493bb36_35126268',
),false); /*/%%SmartyHeaderCode%%*/?>
<?php if ($_valid && !is_callable('content_544e5cf493bb36_35126268')) {function content_544e5cf493bb36_35126268($_smarty_tpl) {?><?php echo $_smarty_tpl->getSubTemplate ("admin/header.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null, array(), 0);?>
 <?php echo $_smarty_tpl->getSubTemplate ("admin/navibar.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null, array(), 0);?>
 <?php echo $_smarty_tpl->getSubTemplate ("admin/sidebar.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null, array(), 0);?>


<link rel="stylesheet" type="text/css"
	href="<?php echo @constant('WEBSITE_URL');?>
/public/assets/lib/jquery-easyui-1.3.4/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css"
	href="<?php echo @constant('WEBSITE_URL');?>
/public/assets/lib/jquery-easyui-1.3.4/themes/icon.css">
<script type="text/javascript"
	src="<?php echo @constant('WEBSITE_URL');?>
/public/assets/lib/jquery-easyui-1.3.4/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="<?php echo @constant('WEBSITE_URL');?>
public/assets/lib/ajaxupload.js"></script>
<style>
#addwin {
	margin: -500px 0 0 -280px;
	/* PLAY THE WITH THE VALUES TO SEE GET THE DESIRED EFFECT */
}
</style>
<script type="text/javascript">


//文件上传组件处理
jQuery(function () {
	 	var button = jQuery('#selectfile');//绑定事件
	var load = new AjaxUpload(button, {//绑定AjaxUpload
    action: "<?php echo @constant('WEBSITE_URL');?>
admin/fileupload/fileup",//文件要上传到的处理页面,语言可以PHP,ASP,JSP等
    type:"POST",//提交方式
    data:{//还可以提交的值
        module:"ajaxupload",
        type:jQuery("#__mstype__").attr("value"),
    },
    autoSubmit:true,//选择文件后,是否自动提交.这里可以变成true,自己去看看效果吧.
    name:'msUploadFile',//提交的名字
    onChange:function(file,ext){//当选择文件后执行的方法,ext存在文件后续,可以在这里判断文件格式
		$("#user_image").attr("value",file);
    },
    onSubmit: function (file, ext) {//提交文件时执行的方法
    	if(ext && /^(jpg|jpeg|png|gif)$/.test(ext)){
			//ext是后缀名
    		button.value = "正在上传…";
    		button.disabled = "disabled";
		}else{	
			alert("不支持的文件格式！只能上传jpg|jpeg|png|gif") ;
			return false;
		}
    },
    onComplete: function (file, response) {//文件提交完成后可执行的方法
        button.text('浏览');
        this.enable();
		var data=eval("("+response+")");
		if(data.type==0){
			alert(data.message);
		}else{
			$('#user_image').val(data.filename);
		}
    }
});
//	var submit=jQuery('#subm').click(function(){//触发提交的事件.与autoSubmit的设置有关,是否采用
//		load.submit();
//});
});

	loadRoles();
	function addWindow(){
		 loadRoles();
		modelshow();
	}

	 function modelshow(){ 
		 $('#addwin').modal('show');
	 }
	 function modelhide(){
		 $('#addwin').modal('hide');
	 }
	 
	 
	function newUser(){
		$("#form").form('clear');
		 loadRoles();
		modelshow();
	}
	function editUser(){
		var select = getSelectUser();
		if(select == null || select.length == 0 ){
			$.messager.alert('错误','请选择要修改的记录!');
			return;
		}
	
		$("#form").form('clear');
		modelshow();
		$("#form").form('load',select[0]);
	
	}
	function removeUser(){
		$.messager.confirm('删除确定','确定要删除当前选择的记录!',function(r){
		    if (r){
		    	var select = getSelectUser();
				if(select == null || select.length == 0 ){
					$.messager.alert('错误','请选择要删除的记录!');
					return;
				}
				$.ajax({  
		            type: "POST",  
		            dataType: "json",  
		            url: '<?php echo @constant('WEBSITE_URL');?>
admin/adminuser/delete',
		            data: { id: select[0].id },  
		            success: function (data) {  
		             	$('#grid').datagrid('reload'); 
		            },  
		            error: function () {  
		            }  
		        });  
		    }
		});
		
	}


	function submitStatusChange(){
		  if(!$('#form').form('validate')){
		        return;
		     }
	    $.post(
				'<?php echo @constant('WEBSITE_URL');?>
admin/adminuser/addOrModify',
				$('#form').serialize(),
				function(data){ 
					modelhide();
			    	$('#grid').datagrid('reload'); 
				},
				"json"
	    );
	}
	  
	function win_close(){
		modelhide();
	}


	function getSelectUser(){
		var select  = $("#grid").datagrid('getSelections');
		if(select == null || select.length == 0 ){
			return null;
		}
		return select;
	}


	 var roles;
		function loadRoles(){
			 if(roles != null){
				 document.getElementById("role_id").innerHTML=createOptions(roles);  
				 return;
			 }
			 $.ajax({
		            type: "POST",
		            url: '<?php echo @constant('WEBSITE_URL');?>
admin/adminuser/getallrole',
		            success:function(data){
		            	 var data = $.parseJSON(data);
		            	 roles = data;
			    		 document.getElementById("role_id").innerHTML=createOptions(data);  
				    },
		            error: function () {
		            }
		        });

			
		 }
		  function createOptions(data){
			 var name = "";
			 for(var i=0;data!=null&&i<data.length;i++){  
			   var cudata=data[i];  
			   name=name+"<option value='"+cudata.role_id+"'>"+cudata.role_name+"</option>"  
			 }  
			 return name;
		 }
		 
</script>

<div class="content">
	<div class="header">
		<div class="stats">
			<p class="stat">
				<!--span class="number"></span-->
			</p>
		</div>

		<h1 class="page-title">后台管理员管理</h1>
	</div>

	<!-- <ul class="breadcrumb">
            <li><a href="<?php echo @constant('WEBSITE_URL');?>
admin/user">管理列表</a> <span class="divider">/</span></li>  
			 <a title= "移除快捷菜单" ><li class="active"><i class="icon-minus" method="del" url="#"></i></li></a>
	         <a title= "加入快捷菜单" ><li class="active"><i class="icon-plus" method="add" url="#"></i></li></a>
        </ul> -->
	<div class="container-fluid">
		<div class="row-fluid">
			<div class="bb-alert alert alert-info" style="display: none;">
				<span>操作成功</span>
			</div>
			<!--- START 以上内容不需更改，保证该TPL页内的标签匹配即可 --->


			<table id="grid"
				data-options="url:'admin/adminuser/getpage',fitColumns:true,singleSelect:true"
				class="easyui-datagrid" style="width: auto; height: 350px"
				toolbar="#toolbar" iconCls="icons-save" pagination="true"
				rownumbers="true">
				<thead>
					<tr>
						<th data-options="field:'passwd',hidden:true"></th>
						<th data-options="field:'role_id',hidden:true"></th>
						<th data-options="field:'id',width:100,checkbox:true"></th>
						<th data-options="field:'user_name',width:100">登陆名</th>
						<th data-options="field:'real_name',width:100">姓名</th>
							<th data-options="field:'role_name',width:100">角色名</th>
						<th data-options="field:'user_image',width:100">用户头像</th>
						<th data-options="field:'mobile',width:100">手机</th>
						<th data-options="field:'email',width:100">邮箱</th>
						<th data-options="field:'login_time',width:100">登陆时间</th>
						<th data-options="field:'login_ip',width:100">登陆IP</th>
						<th data-options="field:'user_desc',width:100">描述</th>
					
					</tr>
				</thead>
			</table>

			<div id="toolbar">
				<a  class="easyui-linkbutton" href="javascript:void(0)"  iconCls="icons-add"
					plain="true" onclick="newUser()">添加新用户</a> <a  href="javascript:void(0)" 
					class="easyui-linkbutton" iconCls="icons-edit" plain="true"
					onclick="editUser()">修改用户信息</a> <a  href="javascript:void(0)" 
					class="easyui-linkbutton" iconCls="icons-remove" plain="true"
					onclick="removeUser()">删除用户</a>
			</div>



			<div id="addwin" class="modal hide fade">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">&times;</button>
					<h5>用户信息管理</h5>
				</div>
				<div class="modal-body">
					<form id="form" method="post" class="form-horizontal">
						<div class="control-group" hidden="true">
							<input type="text" name="id" hidden="true">
						</div>
						<div class="control-group">
							<label class="control-label" for="Text input">登陆名:</label>
							<div class="controls">
								<input type="text" class="easyui-validatebox"
									data-options="required:true" id="user_name" name="user_name"
									placeholder="请输入名称">
							</div>
						</div>
						<div class="control-group">
							<label class="control-label" for="inputPassword">密码:</label>
							<div class="controls">
								<input type="password" class="easyui-validatebox"
									data-options="required:true" id="passwd" name="passwd"
									placeholder="请输入密码">
							</div>
						</div>

						<div class="control-group">
							<label class="control-label" for="Text input">姓名:</label>
							<div class="controls">
								<input type="text" id="real_name" name="real_name"
									placeholder="姓名">
							</div>
						</div>


						<div class="control-group">
							<label class="control-label" for="Text input">用户角色:</label>
							<div class="controls">
								<select id="role_id" name="role_id">
								</select>
							</div>
						</div>

						<div class="control-group">
							<label class="control-label" for="Text input">手机:</label>
							<div class="controls">
								<input type="text" id="mobile" name="mobile" placeholder="手机">
							</div>
						</div>
						<div class="control-group">
							<label class="control-label" for="inputEmail">邮件:</label>
							<div class="controls">
								<input type="text" id="email" name="email" placeholder="Email">
							</div>
						</div>




						<div class="control-group" id="imguploadchose">
							<label class="control-label" for="Text input">头像上传:</label>
							<div class="controls">
								<input type="text" id="user_image" name="user_image"
									placeholder="图片地址位置" class="input-style4 textinput-w3" /> <input
									type="button" class="btn btn-small" id="selectfile"  value="图片选择" />
							</div>
						</div>

						<div class="control-group">
							<label class="control-label" for="Text input">描述:</label>
							<div class="controls">
								<textarea rows="2" name="user_desc"></textarea>
							</div>
						</div>
					</form>
				</div>
				<div class="modal-footer" id="div_view">
					<button type="button" style="width: 100px;" class="btn btn-primary"
						onclick="submitStatusChange()">提交</button>
					<button type="button" onclick="win_close()" style="width: 100px;"
						class="btn">取消</button>

				</div>
			</div>

			<!--- END 以下内容不需更改，请保证该TPL页内的标签匹配即可 --->
			<?php echo $_smarty_tpl->getSubTemplate ("admin/footer.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null, array(), 0);?>
<?php }} ?>